/// 应用字符串资源
/// 支持中英文多语言
class AppStrings {
  // 私有构造函数，防止实例化
  AppStrings._();

  // ==================== 通用文本 ====================
  
  static const Map<String, Map<String, String>> _strings = {
    // 通用按钮和操作
    'confirm': {
      'zh': '确认',
      'en': 'Confirm',
    },
    'cancel': {
      'zh': '取消',
      'en': 'Cancel',
    },
    'save': {
      'zh': '保存',
      'en': 'Save',
    },
    'delete': {
      'zh': '删除',
      'en': 'Delete',
    },
    'edit': {
      'zh': '编辑',
      'en': 'Edit',
    },
    'add': {
      'zh': '添加',
      'en': 'Add',
    },
    'search': {
      'zh': '搜索',
      'en': 'Search',
    },
    'filter': {
      'zh': '筛选',
      'en': 'Filter',
    },
    'sort': {
      'zh': '排序',
      'en': 'Sort',
    },
    'refresh': {
      'zh': '刷新',
      'en': 'Refresh',
    },
    'loading': {
      'zh': '加载中...',
      'en': 'Loading...',
    },
    'retry': {
      'zh': '重试',
      'en': 'Retry',
    },
    'done': {
      'zh': '完成',
      'en': 'Done',
    },
    'next': {
      'zh': '下一步',
      'en': 'Next',
    },
    'previous': {
      'zh': '上一步',
      'en': 'Previous',
    },
    'skip': {
      'zh': '跳过',
      'en': 'Skip',
    },
    'close': {
      'zh': '关闭',
      'en': 'Close',
    },
    'back': {
      'zh': '返回',
      'en': 'Back',
    },
    
    // ==================== 应用标题 ====================
    
    'app_name': {
      'zh': 'Cloud Mood',
      'en': 'Cloud Mood',
    },
    'app_description': {
      'zh': '情绪记录与疗愈应用',
      'en': 'Mood Recording & Healing App',
    },
    'app_slogan': {
      'zh': '记录心情，分析趋势，获得内心平静',
      'en': 'Record moods, analyze trends, find inner peace',
    },
    
    // ==================== 导航标题 ====================
    
    'nav_home': {
      'zh': '首页',
      'en': 'Home',
    },
    'nav_record': {
      'zh': '记录',
      'en': 'Record',
    },
    'nav_history': {
      'zh': '历史',
      'en': 'History',
    },
    'nav_analytics': {
      'zh': '分析',
      'en': 'Analytics',
    },
    'nav_settings': {
      'zh': '设置',
      'en': 'Settings',
    },
    
    // ==================== 首页 ====================
    
    'home_title': {
      'zh': '今日心情',
      'en': 'Today\'s Mood',
    },
    'home_greeting_morning': {
      'zh': '早上好',
      'en': 'Good Morning',
    },
    'home_greeting_afternoon': {
      'zh': '下午好',
      'en': 'Good Afternoon',
    },
    'home_greeting_evening': {
      'zh': '晚上好',
      'en': 'Good Evening',
    },
    'home_mood_question': {
      'zh': '今天的心情如何？',
      'en': 'How are you feeling today?',
    },
    'home_record_button': {
      'zh': '记录心情',
      'en': 'Record Mood',
    },
    'home_today_summary': {
      'zh': '今日总结',
      'en': 'Today\'s Summary',
    },
    'home_recent_records': {
      'zh': '最近记录',
      'en': 'Recent Records',
    },
    'home_mood_trend': {
      'zh': '心情趋势',
      'en': 'Mood Trend',
    },
    'home_no_records_today': {
      'zh': '今天还没有记录心情',
      'en': 'No mood recorded today',
    },
    'home_streak_days': {
      'zh': '连续记录 {days} 天',
      'en': '{days} days streak',
    },
    
    // ==================== 情绪类型 ====================
    
    'mood_happy': {
      'zh': '快乐',
      'en': 'Happy',
    },
    'mood_excited': {
      'zh': '兴奋',
      'en': 'Excited',
    },
    'mood_calm': {
      'zh': '平静',
      'en': 'Calm',
    },
    'mood_relaxed': {
      'zh': '放松',
      'en': 'Relaxed',
    },
    'mood_content': {
      'zh': '满足',
      'en': 'Content',
    },
    'mood_neutral': {
      'zh': '中性',
      'en': 'Neutral',
    },
    'mood_tired': {
      'zh': '疲惫',
      'en': 'Tired',
    },
    'mood_stressed': {
      'zh': '压力',
      'en': 'Stressed',
    },
    'mood_anxious': {
      'zh': '焦虑',
      'en': 'Anxious',
    },
    'mood_sad': {
      'zh': '悲伤',
      'en': 'Sad',
    },
    'mood_angry': {
      'zh': '愤怒',
      'en': 'Angry',
    },
    'mood_depressed': {
      'zh': '抑郁',
      'en': 'Depressed',
    },
    
    // ==================== 记录页面 ====================
    
    'record_title': {
      'zh': '记录心情',
      'en': 'Record Mood',
    },
    'record_select_mood': {
      'zh': '选择心情',
      'en': 'Select Mood',
    },
    'record_mood_intensity': {
      'zh': '情绪强度',
      'en': 'Mood Intensity',
    },
    'record_diary_hint': {
      'zh': '写下今天的感受和想法...',
      'en': 'Write down your feelings and thoughts...',
    },
    'record_add_photo': {
      'zh': '添加照片',
      'en': 'Add Photo',
    },
    'record_add_audio': {
      'zh': '录制语音',
      'en': 'Record Audio',
    },
    'record_add_tags': {
      'zh': '添加标签',
      'en': 'Add Tags',
    },
    'record_weather': {
      'zh': '天气',
      'en': 'Weather',
    },
    'record_location': {
      'zh': '位置',
      'en': 'Location',
    },
    'record_save_success': {
      'zh': '心情记录保存成功',
      'en': 'Mood record saved successfully',
    },
    'record_save_failed': {
      'zh': '保存失败，请重试',
      'en': 'Save failed, please try again',
    },
    
    // ==================== 历史页面 ====================
    
    'history_title': {
      'zh': '历史记录',
      'en': 'History',
    },
    'history_calendar_view': {
      'zh': '日历视图',
      'en': 'Calendar View',
    },
    'history_list_view': {
      'zh': '列表视图',
      'en': 'List View',
    },
    'history_filter_all': {
      'zh': '全部',
      'en': 'All',
    },
    'history_filter_this_week': {
      'zh': '本周',
      'en': 'This Week',
    },
    'history_filter_this_month': {
      'zh': '本月',
      'en': 'This Month',
    },
    'history_filter_this_year': {
      'zh': '今年',
      'en': 'This Year',
    },
    'history_no_records': {
      'zh': '暂无记录',
      'en': 'No records',
    },
    'history_search_hint': {
      'zh': '搜索记录内容...',
      'en': 'Search records...',
    },
    'history_delete_confirm': {
      'zh': '确定要删除这条记录吗？',
      'en': 'Are you sure to delete this record?',
    },
    
    // ==================== 分析页面 ====================
    
    'analytics_title': {
      'zh': '趋势分析',
      'en': 'Analytics',
    },
    'analytics_mood_trend': {
      'zh': '情绪趋势',
      'en': 'Mood Trend',
    },
    'analytics_mood_distribution': {
      'zh': '情绪分布',
      'en': 'Mood Distribution',
    },
    'analytics_word_cloud': {
      'zh': '词云图',
      'en': 'Word Cloud',
    },
    'analytics_statistics': {
      'zh': '统计数据',
      'en': 'Statistics',
    },
    'analytics_total_records': {
      'zh': '总记录数',
      'en': 'Total Records',
    },
    'analytics_average_mood': {
      'zh': '平均情绪',
      'en': 'Average Mood',
    },
    'analytics_most_common_mood': {
      'zh': '最常见情绪',
      'en': 'Most Common Mood',
    },
    'analytics_period_7_days': {
      'zh': '最近7天',
      'en': 'Last 7 Days',
    },
    'analytics_period_30_days': {
      'zh': '最近30天',
      'en': 'Last 30 Days',
    },
    'analytics_period_90_days': {
      'zh': '最近90天',
      'en': 'Last 90 Days',
    },
    'analytics_no_data': {
      'zh': '暂无足够数据进行分析',
      'en': 'Not enough data for analysis',
    },
    
    // ==================== 设置页面 ====================
    
    'settings_title': {
      'zh': '设置',
      'en': 'Settings',
    },
    'settings_appearance': {
      'zh': '外观设置',
      'en': 'Appearance',
    },
    'settings_theme': {
      'zh': '主题模式',
      'en': 'Theme Mode',
    },
    'settings_theme_light': {
      'zh': '浅色模式',
      'en': 'Light Mode',
    },
    'settings_theme_dark': {
      'zh': '深色模式',
      'en': 'Dark Mode',
    },
    'settings_theme_system': {
      'zh': '跟随系统',
      'en': 'System',
    },
    'settings_language': {
      'zh': '语言',
      'en': 'Language',
    },
    'settings_language_chinese': {
      'zh': '中文',
      'en': '中文',
    },
    'settings_language_english': {
      'zh': 'English',
      'en': 'English',
    },
    'settings_notifications': {
      'zh': '通知设置',
      'en': 'Notifications',
    },
    'settings_reminder': {
      'zh': '每日提醒',
      'en': 'Daily Reminder',
    },
    'settings_reminder_time': {
      'zh': '提醒时间',
      'en': 'Reminder Time',
    },
    'settings_privacy': {
      'zh': '隐私设置',
      'en': 'Privacy',
    },
    'settings_privacy_mode': {
      'zh': '隐私模式',
      'en': 'Privacy Mode',
    },
    'settings_privacy_mode_desc': {
      'zh': '启用后将隐藏敏感内容',
      'en': 'Hide sensitive content when enabled',
    },
    'settings_data': {
      'zh': '数据管理',
      'en': 'Data Management',
    },
    'settings_backup': {
      'zh': '数据备份',
      'en': 'Data Backup',
    },
    'settings_restore': {
      'zh': '数据恢复',
      'en': 'Data Restore',
    },
    'settings_export': {
      'zh': '导出数据',
      'en': 'Export Data',
    },
    'settings_clear_data': {
      'zh': '清除数据',
      'en': 'Clear Data',
    },
    'settings_about': {
      'zh': '关于',
      'en': 'About',
    },
    'settings_version': {
      'zh': '版本信息',
      'en': 'Version',
    },
    'settings_privacy_policy': {
      'zh': '隐私政策',
      'en': 'Privacy Policy',
    },
    'settings_terms_of_service': {
      'zh': '服务条款',
      'en': 'Terms of Service',
    },
    'settings_feedback': {
      'zh': '意见反馈',
      'en': 'Feedback',
    },
    
    // ==================== 错误消息 ====================
    
    'error_network': {
      'zh': '网络连接失败',
      'en': 'Network connection failed',
    },
    'error_file_not_found': {
      'zh': '文件不存在',
      'en': 'File not found',
    },
    'error_permission_denied': {
      'zh': '权限被拒绝',
      'en': 'Permission denied',
    },
    'error_storage_full': {
      'zh': '存储空间不足',
      'en': 'Storage space insufficient',
    },
    'error_database': {
      'zh': '数据库操作失败',
      'en': 'Database operation failed',
    },
    'error_unknown': {
      'zh': '发生未知错误',
      'en': 'Unknown error occurred',
    },
    'error_file_too_large': {
      'zh': '文件过大',
      'en': 'File too large',
    },
    'error_unsupported_format': {
      'zh': '不支持的文件格式',
      'en': 'Unsupported file format',
    },
    
    // ==================== 成功消息 ====================
    
    'success_save': {
      'zh': '保存成功',
      'en': 'Saved successfully',
    },
    'success_delete': {
      'zh': '删除成功',
      'en': 'Deleted successfully',
    },
    'success_update': {
      'zh': '更新成功',
      'en': 'Updated successfully',
    },
    'success_export': {
      'zh': '导出成功',
      'en': 'Exported successfully',
    },
    'success_import': {
      'zh': '导入成功',
      'en': 'Imported successfully',
    },
    'success_backup': {
      'zh': '备份成功',
      'en': 'Backup successful',
    },
    'success_restore': {
      'zh': '恢复成功',
      'en': 'Restore successful',
    },
    
    // ==================== 确认对话框 ====================
    
    'confirm_delete_record': {
      'zh': '确定要删除这条记录吗？此操作无法撤销。',
      'en': 'Are you sure to delete this record? This action cannot be undone.',
    },
    'confirm_clear_all_data': {
      'zh': '确定要清除所有数据吗？此操作无法撤销。',
      'en': 'Are you sure to clear all data? This action cannot be undone.',
    },
    'confirm_logout': {
      'zh': '确定要退出登录吗？',
      'en': 'Are you sure to logout?',
    },
    
    // ==================== 时间相关 ====================
    
    'time_today': {
      'zh': '今天',
      'en': 'Today',
    },
    'time_yesterday': {
      'zh': '昨天',
      'en': 'Yesterday',
    },
    'time_this_week': {
      'zh': '本周',
      'en': 'This Week',
    },
    'time_last_week': {
      'zh': '上周',
      'en': 'Last Week',
    },
    'time_this_month': {
      'zh': '本月',
      'en': 'This Month',
    },
    'time_last_month': {
      'zh': '上月',
      'en': 'Last Month',
    },
    'time_this_year': {
      'zh': '今年',
      'en': 'This Year',
    },
    'time_morning': {
      'zh': '上午',
      'en': 'AM',
    },
    'time_afternoon': {
      'zh': '下午',
      'en': 'PM',
    },
    'time_evening': {
      'zh': '晚上',
      'en': 'Evening',
    },
    
    // ==================== 天气相关 ====================
    
    'weather_sunny': {
      'zh': '晴天',
      'en': 'Sunny',
    },
    'weather_cloudy': {
      'zh': '多云',
      'en': 'Cloudy',
    },
    'weather_rainy': {
      'zh': '雨天',
      'en': 'Rainy',
    },
    'weather_snowy': {
      'zh': '雪天',
      'en': 'Snowy',
    },
    'weather_windy': {
      'zh': '大风',
      'en': 'Windy',
    },
    'weather_foggy': {
      'zh': '雾天',
      'en': 'Foggy',
    },
  };
  
  /// 获取本地化字符串
  /// [key] 字符串键
  /// [languageCode] 语言代码，默认为中文
  /// [params] 参数替换映射
  static String get(String key, {String languageCode = 'zh', Map<String, String>? params}) {
    final stringMap = _strings[key];
    if (stringMap == null) {
      return key; // 如果找不到键，返回键本身
    }
    
    String text = stringMap[languageCode] ?? stringMap['zh'] ?? key;
    
    // 参数替换
    if (params != null) {
      params.forEach((paramKey, paramValue) {
        text = text.replaceAll('{$paramKey}', paramValue);
      });
    }
    
    return text;
  }
  
  /// 获取中文字符串
  /// [key] 字符串键
  /// [params] 参数替换映射
  static String zh(String key, {Map<String, String>? params}) {
    return get(key, languageCode: 'zh', params: params);
  }
  
  /// 获取英文字符串
  /// [key] 字符串键
  /// [params] 参数替换映射
  static String en(String key, {Map<String, String>? params}) {
    return get(key, languageCode: 'en', params: params);
  }
  
  /// 检查是否存在指定的字符串键
  /// [key] 字符串键
  static bool hasKey(String key) {
    return _strings.containsKey(key);
  }
  
  /// 获取所有支持的语言代码
  static List<String> getSupportedLanguages() {
    return ['zh', 'en'];
  }
  
  /// 获取所有字符串键
  static List<String> getAllKeys() {
    return _strings.keys.toList();
  }
}